package com.nowcoder.community.util;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.DigestUtils;

import java.util.UUID;

public class CommunityUtil {
    //生成随机字符串
    public static String generateUUID(){
        //去掉-和空字符串
        return UUID.randomUUID().toString().replace("-","");
    }
    //MD5算法加密
    //下面那几个都是java自带的
    public static String md5(String key){
        if(StringUtils.isAllBlank(key)){
            return null;
        }
        return DigestUtils.md5DigestAsHex(key.getBytes());
    }
}
